<template>
    <div class="wrapper">
        <v-head></v-head>
        <div class="content-box" :class="{'content-collapse':collapse}">
            <div class="content">
                <transition name="move" mode="out-in">
                    <keep-alive :include="tagsList">
                        <router-view></router-view>
                    </keep-alive>
                </transition>
            </div>
        </div>
    </div>
</template>

<script>
    import vHead from './Header.vue';
    import bus from './bus';
    export default {
        data(){
            return {
                tagsList: [],
                collapse: false
            }
        },
        components:{
            vHead
        },
        //页面跳转是监听路由变化；
        watch:{
            $route(to,from){
              
            }
        },
        created(){
            bus.$on('collapse', msg => {
                this.collapse = msg;
            })
            
            // 只有在标签页列表里的页面才使用keep-alive，即关闭标签之后就不保存到内存中了。
            bus.$on('tags', msg => {
                let arr = [];
                for(let i = 0, len = msg.length; i < len; i ++){
                    msg[i].name && arr.push(msg[i].name);
                }
                this.tagsList = arr;
            })
        },
        methods:{
            
        }
    }
</script>
<style scoped>
.wrapper {
    width: 100%;
    height: 100%;
    overflow: hidden;
}
.content-box {
    position: absolute;
    /* left: 250px; */
    left: 0;
    right: 0;
    top: 60px;
    bottom: 0;
    overflow-y: scroll;
    -webkit-transition: left .3s ease-in-out;
    transition: left .3s ease-in-out;
    background: #f0f0f0;
}
.title{
    line-height: 64px;
    font-size: 32px;
    font-weight: bold;
    border-bottom: 3px solid firebrick;
    margin-bottom: 10px;
    color: #333;
}
.content {
    width: auto;
    padding: 0 20px 0px 20px;
}
</style>
